{extend name="public/base"/}
{block name="style"}
<link href="__PUBLIC__/ieasy/css/classify.css?v=2.1.49" rel="stylesheet" type="text/css">
{/block}
{block name="body"}
<div id="console_main"></div>
<div class="head_tit_box">
	<a href="javascript:;" class="head_return_page_but"></a>
		<div class="head_menu_but_box">
		<a href="javascript:;" class="head_menu_but"></a>
	</div>
		<h1>分类</h1>
</div>
<!--导航-->
{block name="include"}{include file="public:dropnav" /}{/block}
<div class="body_sytle">
	
	<div class="c_list_box">
		
		<div class="c_list_tab_box">
			<a href="javascript:;" class="hover" sex="1">男生</a>
			<a href="javascript:;" sex="2">女生</a>
		</div>
		
		<ul class="c_list_ul"></ul>
	</div>
	
</div>
<!--活动弹框-->
<div style="display: none;"  class="christmas_popup_box">
<div class="christmas_body">
	<div class="christmas_main">
		<a href="javascript:;" class="christmas_close_2"></a>
			</div>
</div>
<div class="christmas_jgb"></div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.min.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.cookie.min.js?v=2.1.49"></script>

<!-- 这是zepto插件 -->

<script type="text/javascript" src="__PUBLIC__/ieasy/js/common.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/cps_log.js?v=2.1.49"></script>

<!-- 这里引入js -->
<script type="text/javascript">
	$(function(){
		var sex  = 1;
		loadCategories(sex);
		$(".c_list_tab_box > a").click(function(){
			$(this).addClass("hover");
			$(this).siblings().removeClass("hover");
			var sex = $(this).attr("sex");
			loadCategories(sex);
		});
	})

	function loadCategories(sex){
		var opposite = (sex==1) ? 2 : 1;
		$(".sex_"+opposite).hide();
		if(!$(".sex_"+sex).length){
			makeCategoryHtml(sex);
		}
		$(".sex_"+sex).show();
	}

	function makeCategoryHtml(sex){
		$.get("/api/index/getcategory",{'sex':sex},function(data){
			$.each(data,function(key,value){
				console.log(sex);
			    var imgList = [
			        "__PUBLIC__/ieasy/img/classify_icon_1.png",
			        "__PUBLIC__/ieasy/img/classify_icon_2.png",
			        "__PUBLIC__/ieasy/img/classify_icon_3.png",
			        "__PUBLIC__/ieasy/img/classify_icon_4.png",
			        "__PUBLIC__/ieasy/img/classify_icon_5.png",
			        "__PUBLIC__/ieasy/img/classify_icon_6.png",
			        "__PUBLIC__/ieasy/img/classify_icon_7.png"
                ];
				var simg = imgList[(key % 7)];
				if(value.image){
					simg = value.image;
				}
				
				var item = '<li class="sex_'+sex+'">';
					item +='<a href="/books.html?channel='+sex+'&cate='+value.id+'&catename='+value.name+'">';
					item +='<span>' +value.name+ '</span>';
					item +='<img src="'+simg+'" />';
					item +='</a>';
					item +='</li>';
				$("ul.c_list_ul").append(item);
			});
		});
	}
</script>
{/block}